import 'dart:convert';

import '../../entity/app_version.dart';
import '../../entity/palette_model.dart';

class PaletteLoader {
  static PaletteModel load(String json) {
    Map<String, dynamic> jsonMap = jsonDecode(json);
    var ver = AppVersion.fromVersionString(jsonMap['version']);
    if (ver == null) {
      return PaletteModel.fromJson({});
    }
    switch (ver) {
      case AppVersion.v0_0_1:
        return _loadV0_0_1(jsonMap);
    }
  }

  static PaletteModel _loadV0_0_1(Map<String, dynamic> jsonMap) {
    return PaletteModel.fromJson(jsonMap);
  }
}
